package com.itboye.mybatis.enumtype;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * UserRoles.java
 * Created on  2016/7/22 17:11
 * 版本       修改时间          作者      修改内容
 * V1.0.1    2016/7/22      hebidu    初始版本
 * 用户角色枚举
 * Copyright (c) 2013 杭州博也网络科技有限公司 版权所有
 * HANGZHOU BOYE TECHNOLOGY CO.,LTD. All Rights Reserved.
 */
@JsonSerialize(using = UserRolesSerializer.class)
public enum  UserRoles {

    UNKNOWN("未知",-1),
    STUDENT("学生",5),
    ENTERPRISE("企业",6),
    SCHOOL("学校",7),
    GOVERNMENT("政府",8);

    @Override
    public String toString() {
        return "UserRoles{" +
                "desc='" + desc + '\'' +
                ", roles=" + roles +
                '}';
    }

    UserRoles(String desc, int roles) {
        this.desc = desc;
        this.roles = roles;
    }

    public static UserRoles getUserRoles(int roleValue){
        UserRoles[] values =  UserRoles.values();

        for (UserRoles role:values) {
            if(role.getRoles() == roleValue){
                return role;
            }
        }

        return UserRoles.UNKNOWN;
    }


    private String desc;
    private int roles;

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public int getRoles() {
        return roles;
    }

    public void setRoles(int roles) {
        this.roles = roles;
    }
}
